﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.TPYRS
{
    class Class1
    {
        public void Calc200(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period <= 20 && ppa.Age < 60)
            {
                if ((ppa.Period + 1) % 2 == 0)
                {
                    da.Value = ppa.Amount * 0.08;
                }

            }
            else
            {
                da.Value = ppa.Amount * 0.05;
            }


        }

        public void Calc200(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if ((ppa.Period + 1) % 2 == 0)
            {
                da.Value = ppa.Amount * 0.18;
            }

            if (ppa.Age >= 61 && (ppa.Age - 61) % 5 == 0 && ppa.Age <= 86)
            {
                da.Value += ppa.Amount * 0.18;
            }


        }

        public void Calc200(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
            {
                if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee;
                }
                else
                {
                    double f=ppa.GetDutyTotalValue("祝寿金");
                    double a1 = ppa.Amount *5 - f;
                    double a2 = ppa.TotalFee * 1.08 - f;

                    da.Value = a1 > a2 ? a1 : a2;
                    ppa.SchemePeriodActing.InsurantStates.Add("身故");
                    ppa.IsCurrentFinish = true;
                }
            }
            else if (ppa.SchemePeriodActing.InsurantStates.Contains("非意外身故"))
            {
                if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee;
                }
                else
                {
                    double f = ppa.GetDutyTotalValue("祝寿金");
                    double a1 = ppa.Amount * 2 - f;
                    double a2 = ppa.TotalFee * 1.08 - f;

                    da.Value = a1 > a2 ? a1 : a2;
                    ppa.SchemePeriodActing.InsurantStates.Add("身故");
                    ppa.IsCurrentFinish = true;
                }
            }

            if (ppa.Period > 0)
            {
                double f = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("分红率(预估)");

                da.Value = ppa.TotalFee * f;
            }
        }

        public void Calc200(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故"))
            {
                if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee;
                }
                else
                {
                    double a1 = ppa.Amount * 2;
                    double a2 = ppa.TotalFee;

                    da.Value = a1 > a2 ? a1 : a2;
                    ppa.IsCurrentFinish = true;
                }
            }
           
        }

        public void Calc200(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period > 0)
            {
                double f = (double)ppa.SchemePeriodActing.SchemeActing.GetAuxConfigValue("分红率(预估)");

                ppa.Amount += ppa.PolicyActing.PeriodActings[ppa.Period - 1].Amount * f;
            }

            if (ppa.SchemePeriodActing.InsurantStates.Contains("身故")|| ppa.SchemePeriodActing.InsurantStates.Contains("全残"))
            {
                if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee + ppa.Amount * 0.5;
                }
                else
                {
                    da.Value = ppa.Amount;   
                }
                ppa.IsCurrentFinish = true;
            }

        }
    }
}
